const cos = require('../../../../oss/init.js')
const constant = require('../../../../constant/index.js')
const redis = require('../../../../redis/init.js')
//获取文章分类进行匹配
const userDownload = async (req,res,next) => {
const {article_title,category_id} = req.body
const getArticleCategory = JSON.parse(await redis.get('/api/category'))
const category = getArticleCategory.find(item => item.id === category_id)
cos.getObjectUrl({
        Bucket:constant.BUCKET,
        Region:constant.REGION,
        Key:`docs/${category.category}/${article_title}`,
        Sign:true,
        Expires:60*60*24
    },(err,data) => {
        if(err){
            res.send({
                code:500,
                message:err
            })
        }
    
        res.send({
            code:200,
            data
        })
    })
}
module.exports = userDownload